package org.example.exception;

import org.example.common.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalException {

    @ExceptionHandler(ServiceException.class)
    public R<Void> serviceException(ServiceException e) {
        e.printStackTrace();
        return R.fail(e.getMessage(),e.getCode());
    }

    @ExceptionHandler(Exception.class)
    public R<Void> exception(Exception e) {
        e.printStackTrace();
        return R.fail(e.getMessage());
    }

}
